/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.pojo;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Yasith
 */
@Entity
@Table(name = "countries")
@NamedQueries({@NamedQuery(name = "Country.findByCountryID", query = "SELECT c FROM Country c WHERE c.countryID = :countryID"), @NamedQuery(name = "Country.findByName", query = "SELECT c FROM Country c WHERE c.name = :name"), @NamedQuery(name = "Country.findByTimestamp", query = "SELECT c FROM Country c WHERE c.timestamp = :timestamp")})
public class Country implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Column(name = "countryID", nullable = false)
    private Integer countryID;
    @Column(name = "name", nullable = false)
    private String name;
    @Column(name = "timestamp", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date timestamp;
    @OneToMany(mappedBy = "countryID")
    private Collection<UserProfile> userprofilesCollection;

    public Country() {
    }

    public Country(Integer countryID) {
        this.countryID = countryID;
    }

    public Country(Integer countryID, String name, Date timestamp) {
        this.countryID = countryID;
        this.name = name;
        this.timestamp = timestamp;
    }

    public Integer getCountryID() {
        return countryID;
    }

    public void setCountryID(Integer countryID) {
        this.countryID = countryID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public Collection<UserProfile> getUserprofilesCollection() {
        return userprofilesCollection;
    }

    public void setUserprofilesCollection(Collection<UserProfile> userprofilesCollection) {
        this.userprofilesCollection = userprofilesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (countryID != null ? countryID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Country)) {
            return false;
        }
        Country other = (Country) object;
        if ((this.countryID == null && other.countryID != null) || (this.countryID != null && !this.countryID.equals(other.countryID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.pojo.Country[countryID=" + countryID + "]";
    }

}
